package com.shuoyue.adven.main.appcontrol;

import android.content.Context;
import android.util.Log;

import startest.ys.com.poweronoff.PowerOnOffManager;

public class PowerUtil {

    /**
     * 设置周期开启时间,每日6点到次日0点
     * @param context
     */
    public static void setPowerWeek(Context context) {
        PowerOnOffManager powerOnOffManager = PowerOnOffManager.getInstance(context);
        int[] timeonArray = new int[]{21, 45};
        int[] timeoffArray = new int[]{21, 40};
        int[] weekdays = new int[]{
                1, 1, 1, 1, 1, 1, 1
        };//周一到周日工作状态,1为开机，0为不开机
        powerOnOffManager.setPowerOnOffWithWeekly(timeonArray, timeoffArray, weekdays);
    }

    public static void setPowerOneTime(Context context, int[] timeonArray ,int[] timeoffArray) {
        Log.e("设置开关开机","");
        PowerOnOffManager powerOnOffManager = PowerOnOffManager.getInstance(context);
        powerOnOffManager.setPowerOnOff(timeonArray, timeoffArray);
    }

    public static void powerOff(Context context) {
        PowerOnOffManager powerOnOffManager = PowerOnOffManager.getInstance(context);
        powerOnOffManager.shutdown();
    }

    public static void clear(Context c) {
        PowerOnOffManager powerOnOffManager = PowerOnOffManager.getInstance(c);
        powerOnOffManager.clearPowerOnOffTime();
    }

    public static String getPowerOnTime(Context c) {
        PowerOnOffManager powerOnOffManager = PowerOnOffManager.getInstance(c);
        String time = powerOnOffManager.getPowerOnTime();
        return time;
    }

    public static String getPowerOffTime(Context c) {
        PowerOnOffManager powerOnOffManager = PowerOnOffManager.getInstance(c);
        String time = powerOnOffManager.getPowerOffTime();
        return time;
    }
}
